package com.taiji.example.controller;

import com.taiji.example.domain.User;
import com.taiji.example.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenzhe
 * @version 1.0
 * @date 2021/5/26
 * @describe
 */
@Api(tags = {"11.用户接口"})
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    @ApiOperation(value = "用户新增")
    public User add(@RequestBody User user) {
        User add = userService.add(user);
        return add;
    }

    @RequestMapping("/xie")
    public String add1() {
        return "qiao";
    }

    @PostMapping("/error")
    public String Error(){
        return "登录错误";
    }

    @RequestMapping("/addUser")
    public User addUser(){
        User user = new User();
        user.setUsername("test");
        user.setPassword("test");
        user.setEmail("2546300629@163.com");
        return userService.addUser(user);
    }
}
